package com.runen.infinitemovement;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;


import com.mob.MobSDK;
import com.runen.infinitemovement.steputil.StepZeroAlarmReceiver;
import com.runen.rxnetlibrary.BaseApplication;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

import java.util.Calendar;
import java.util.TimeZone;

import cn.jpush.android.api.JPushInterface;
import cn.net.shoot.sharetracesdk.ShareTrace;
import cn.sharesdk.framework.ShareSDK;


/**
 * Create by LiaoDuanHong
 * Create on 2020/08/26 15:57
 */
public class App extends BaseApplication {
    public static Context mContext;
    //七牛存放图片位置
    public static final String fileUrl = "Jjt/img/";
    public static Handler mHandler;

    @Override
    public void onCreate() {
        super.onCreate();
        MobSDK.init(this);
//        MobSDK.submitPolicyGrantResult(false, null);
        mContext = getApplicationContext();
        mHandler = new Handler();
        initUmeng();
        //极光推送
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        ShareTrace.init(this);
//        initAlarm();//开启零点定时
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    /**
     * 初始化umeng
     */
    private void initUmeng() {
        /**
         * 注意: 即使您已经在AndroidManifest.xml中配置过appkey和channel值，也需要在App代码中调
         * 用初始化接口（如需要使用AndroidManifest.xml中配置好的appkey和channel值，
         * UMConfigure.init调用中appkey和channel参数请置为null）。
         */
        UMConfigure.init(this, "5f5600cc3739314483bcee2a"
                , "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");//58edcfeb310c93091c000be2 5965ee00734be40b580001a0
        UMConfigure.setLogEnabled(BuildConfig.DEBUG);
        // 选用AUTO页面采集模式
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

            }

            @Override
            public void onActivityStarted(Activity activity) {

            }

            @Override
            public void onActivityResumed(Activity activity) {
                // 选用AUTO页面采集模式
                MobclickAgent.onResume(activity);
                MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
            }

            @Override
            public void onActivityPaused(Activity activity) {
                MobclickAgent.onPause(activity);
            }

            @Override
            public void onActivityStopped(Activity activity) {

            }

            @Override
            public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

            }

            @Override
            public void onActivityDestroyed(Activity activity) {

            }
        });
    }

}
